<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机</title>
</head>
<body>
    <script src="../vue.js"></script>
    <div id="app">
        <ul v-for="(item,index) in list" :key="item.id">
            <li>{{item.name}}</li>
            <button @click="del(item.id)">删除</button>
        </ul>
        <button @click="add()">生成</button>
    </div>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
               list:[]
            },
            methods: {
                add() {
                    this.list.push({id:Date.now(),name:Math.floor(Math.random() * 20)})
                },
                del(id){
                    this.list = this.list.filter(item=>item.id !== id)
                }
            }
        })
    </script>
</body>
</html>